<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>div圆周运动</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box {
        width: 200px;
        height: 200px;
        border: 1px solid blue;
        border-radius: 100%;
        margin: 30px auto 0;
        position: relative;
      }
      .pointer {
        left: 0;
        top: 0;
        position: absolute;
        width: 10px;
        height: 10px;
        background-color: rebeccapurple;
        z-index: 100;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="pointer" id="pointer"></div>
    </div>
    <script>
      let div = document.querySelector('#pointer');
      let R = 100; //半径
      let angle = 0; //开始角度
      function animation() {
        //角度转弧度
        var radians = angle * (Math.PI / 180);
        div.style.left = R * Math.cos(radians) + 100 + 'px';
        div.style.top = R * Math.sin(radians) + 100 + 'px';
        angle = angle + 1;
        requestAnimationFrame(animation);
      }
      animation();
    </script>
  </body>
</html>
